﻿package mortal.game.view.common.guide.stepOperater
{
    import flash.display.*;
    import flash.geom.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.guide.data.*;
    import mortal.game.view.mainUI.shortcutbar.*;
    import mortal.mvc.core.*;

    public class AutoGuideFlyToWizard extends AutoGuideStepBase implements IAutoGuideSteper
    {
        private var _flyEffect:AutoGuideFlyEffectSteper;
        private var _btn:InteractiveObject;
        private var _isFlyEnd:Boolean = false;
        private var _isTweenEnd:Boolean = false;

        public function AutoGuideFlyToWizard()
        {
            return;
        }// end function

        public function guide(param1:AutoGuideData, param2:Window = null) : void
        {
            if (_working)
            {
                this.stop();
            }
            _data = param1;
            if (_data.clickChildName == AutoGuideClickType.SaveRightDownIconShowed)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, param1));
                return;
            }
            this._flyEffect = GameController.autoGuide.flyEffectSteper as AutoGuideFlyEffectSteper;
            this._btn = (GameController.shortcut.view as ShortcutBar).xpBtn;
            var _loc_3:* = this._btn.localToGlobal(new Point(0, 0));
            var _loc_4:* = new AutoGuideData();
            _loc_4.guideTypeValue = int(_loc_3.x + 30).toString() + "," + int(_loc_3.y + 30).toString();
            _loc_4.mainId = -11111;
            _loc_4.stepId = -1;
            this._flyEffect.guide(_loc_4);
            this._flyEffect.preEndCallback = this.startIconTween;
            this._flyEffect.endCallback = this.flyEnd;
            this._isFlyEnd = false;
            this._isTweenEnd = false;
            super.setData(param1, null, this._btn);
            return;
        }// end function

        private function flyEnd() : void
        {
            this._isFlyEnd = true;
            this.checkStop();
            return;
        }// end function

        private function startIconTween() : void
        {
            this._isTweenEnd = true;
            this._btn.filters = [];
            this._btn.mouseEnabled = true;
            this._btn.visible = true;
            return;
        }// end function

        private function iconShowEnd() : void
        {
            this._isTweenEnd = true;
            this.checkStop();
            return;
        }// end function

        private function checkStop() : void
        {
            if (!this._isFlyEnd || !this._isTweenEnd)
            {
                return;
            }
            this.stop(_data);
            return;
        }// end function

        override public function stop(param1:AutoGuideData = null) : void
        {
            super.stop(param1);
            if (param1 != null)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.AutoGuideStepEnd, param1));
            }
            return;
        }// end function

    }
}
